home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgLangD.iso / BORLAND TURBO / 32SNIPIT.PAK / INITENG.C < prev    next >
Encoding:
C/C++ Source or Header  |  1997-05-06  |  2.5 KB  |  69 lines

  1. // BDE32 3.x - (C) Copyright 1996 by Borland International
  2.  
  3. // initeng.c
  4. #include "snipit.h"
  5.  
  6. //========================================================================
  7. //  Function:
  8. //          InitEngSample();
  9. //
  10. //  Description:
  11. //          This code snippet will initialize IDAPI with a NULL
  12. //          environment structure, connect to a Standard database (used by
  13. //          Paradox and dBASE tables), then clean up before returning.
  14. //          Initializing IDAPI with a NULL environment structure will
  15. //          force IDAPI to scan for the needed CFG file. The search
  16. //          will follow this search hierarchy:
  17. //          1. Use the CFG specified in the DBIEnv structure (not
  18. //             supplied by this example.
  19. //          2. Check for a defined CFG file in the WIN.INI file located in
  20. //             your Windows directory. The entry checked for is "[IDAPI]"
  21. //             with an sub-entry of "CONFIGFILE01."
  22. //          3. Check for the CFG file in the startup directory.
  23. //          4. When all else fails, IDAPI will initialize with a
  24. //             predefined set of configuration settings. The default
  25. //             settings include no locking of Paradox or dBASE tables,
  26. //             no network access to tables, and no SQL databases.
  27. //========================================================================
  28. void
  29. InitEngSample (void)
  30. {
  31.     hDBIDb       hDb = 0;      // Handle to the database
  32.     DBIResult    rslt;
  33.  
  34.     Screen("*** Initializing IDAPI ***\r\n");
  35.  
  36.     BREAK_IN_DEBUGGER();
  37.  
  38.     Screen("  Initializing IDAPI...");
  39.  
  40.     rslt = DbiInit(NULL);
  41.     if (ChkRslt(rslt, "Init") == DBIERR_NONE)
  42.     {
  43.         // IDAPI initialized. Now open a Standard database (used to
  44.         // access Paradox, dBASE, and Text tables), by using a NULL
  45.         // database type.
  46.         Screen("  Opening a Standard database...");
  47.  
  48.         rslt = DbiOpenDatabase(NULL, NULL, dbiREADWRITE, dbiOPENSHARED,
  49.                                NULL, 0, NULL, NULL, &hDb);
  50.         if (ChkRslt(rslt, "OpenDatabase") == DBIERR_NONE)
  51.         {
  52.             // Database was opened. Go ahead and close it!
  53.             Screen("  Closing the database...");
  54.             rslt = DbiCloseDatabase(&hDb);
  55.             ChkRslt(rslt, "DbClose");
  56.         }
  57.  
  58.         Screen("  Exiting IDAPI...");
  59.         rslt = DbiExit();
  60.         ChkRslt(rslt, "Exit");
  61.     }
  62.     else
  63.     {
  64.         Screen("    Error - Could not initialize IDAPI");
  65.     }
  66.  
  67.     Screen("\r\n*** End of Example ***");
  68. }
  69.